package b.k.a;

import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import b.f.i;
import b.i.k.o;
import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import java.util.ArrayList;
import java.util.List;
import java.util.WeakHashMap;

/* compiled from: ExploreByTouchHelper */
public abstract class a extends b.i.k.a {
    public static final Rect n = new Rect(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
    public static final b<b.i.k.y.b> o = new a();
    public static final c<i<b.i.k.y.b>, b.i.k.y.b> p = new b();
    public final Rect d = new Rect();
    public final Rect e = new Rect();
    public final Rect f = new Rect();
    public final int[] g = new int[2];
    public final AccessibilityManager h;
    public final View i;
    public c j;
    public int k = Integer.MIN_VALUE;
    public int l = Integer.MIN_VALUE;
    private int m = Integer.MIN_VALUE;

    /* compiled from: ExploreByTouchHelper */
    public static class a implements b<b.i.k.y.b> {
        public void a(Object obj, Rect rect) {
            ((b.i.k.y.b) obj).a.getBoundsInParent(rect);
        }
    }

    /* compiled from: ExploreByTouchHelper */
    public static class b implements c<i<b.i.k.y.b>, b.i.k.y.b> {
    }

    /* compiled from: ExploreByTouchHelper */
    public class c extends b.i.k.y.c {
        public b.i.k.y.b a(int i) {
            return new b.i.k.y.b(AccessibilityNodeInfo.obtain(a.this.q(i).a));
        }

        public b.i.k.y.b b(int i) {
            i = i == 2 ? a.this.k : a.this.l;
            if (i == Integer.MIN_VALUE) {
                return null;
            }
            return new b.i.k.y.b(AccessibilityNodeInfo.obtain(a.this.q(i).a));
        }

        public boolean c(int i, int i2, Bundle bundle) {
            a aVar = a.this;
            if (i != -1) {
                boolean z = true;
                if (i2 == 1) {
                    return aVar.v(i);
                }
                if (i2 == 2) {
                    return aVar.k(i);
                }
                if (i2 == 64) {
                    if (aVar.h.isEnabled() && aVar.h.isTouchExplorationEnabled()) {
                        i2 = aVar.k;
                        if (i2 != i) {
                            if (i2 != Integer.MIN_VALUE) {
                                aVar.j(i2);
                            }
                            aVar.k = i;
                            aVar.i.invalidate();
                            aVar.w(i, 32768);
                            return z;
                        }
                    }
                    z = false;
                    return z;
                } else if (i2 != AesLen.ROOTKEY_COMPONET_LEN) {
                    return aVar.r(i, i2, bundle);
                } else {
                    return aVar.j(i);
                }
            }
            View view = aVar.i;
            WeakHashMap weakHashMap = o.a;
            return view.performAccessibilityAction(i2, bundle);
        }
    }

    public a(View view) {
        if (view != null) {
            this.i = view;
            this.h = (AccessibilityManager) view.getContext().getSystemService("accessibility");
            view.setFocusable(true);
            WeakHashMap weakHashMap = o.a;
            if (view.getImportantForAccessibility() == 0) {
                view.setImportantForAccessibility(1);
                return;
            }
            return;
        }
        throw new IllegalArgumentException("View may not be null");
    }

    public b.i.k.y.c b(View view) {
        if (this.j == null) {
            this.j = new c();
        }
        return this.j;
    }

    public void c(View view, AccessibilityEvent accessibilityEvent) {
        this.a.onInitializeAccessibilityEvent(view, accessibilityEvent);
    }

    public void d(View view, b.i.k.y.b bVar) {
        this.a.onInitializeAccessibilityNodeInfo(view, bVar.a);
        s(bVar);
    }

    public final boolean j(int i) {
        if (this.k != i) {
            return false;
        }
        this.k = Integer.MIN_VALUE;
        this.i.invalidate();
        w(i, 65536);
        return true;
    }

    public final boolean k(int i) {
        if (this.l != i) {
            return false;
        }
        this.l = Integer.MIN_VALUE;
        u(i, false);
        w(i, 8);
        return true;
    }

    public final b.i.k.y.b l(int i) {
        AccessibilityNodeInfo obtain = AccessibilityNodeInfo.obtain();
        b.i.k.y.b bVar = new b.i.k.y.b(obtain);
        obtain.setEnabled(true);
        bVar.a.setFocusable(true);
        bVar.a.setClassName("android.view.View");
        Rect rect = n;
        bVar.a.setBoundsInParent(rect);
        bVar.a.setBoundsInScreen(rect);
        View view = this.i;
        bVar.b = -1;
        bVar.a.setParent(view);
        t(i, bVar);
        if (bVar.g() == null && bVar.e() == null) {
            throw new RuntimeException("Callbacks must add text or a content description in populateNodeForVirtualViewId()");
        }
        bVar.a.getBoundsInParent(this.e);
        if (this.e.equals(rect)) {
            throw new RuntimeException("Callbacks must set parent bounds in populateNodeForVirtualViewId()");
        }
        int actions = bVar.a.getActions();
        if ((actions & 64) != 0) {
            throw new RuntimeException("Callbacks must not add ACTION_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()");
        } else if ((actions & AesLen.ROOTKEY_COMPONET_LEN) == 0) {
            Rect rect2;
            bVar.a.setPackageName(this.i.getContext().getPackageName());
            view = this.i;
            bVar.c = i;
            bVar.a.setSource(view, i);
            int i2 = 0;
            if (this.k == i) {
                bVar.a.setAccessibilityFocused(true);
                bVar.a.addAction(AesLen.ROOTKEY_COMPONET_LEN);
            } else {
                bVar.a.setAccessibilityFocused(false);
                bVar.a.addAction(64);
            }
            boolean z = this.l == i;
            if (z) {
                bVar.a.addAction(2);
            } else if (bVar.a.isFocusable()) {
                bVar.a.addAction(1);
            }
            bVar.a.setFocused(z);
            this.i.getLocationOnScreen(this.g);
            bVar.a.getBoundsInScreen(this.d);
            if (this.d.equals(rect)) {
                bVar.a.getBoundsInParent(this.d);
                if (bVar.b != -1) {
                    b.i.k.y.b bVar2 = new b.i.k.y.b(AccessibilityNodeInfo.obtain());
                    for (i = bVar.b; i != -1; i = bVar2.b) {
                        view = this.i;
                        bVar2.b = -1;
                        bVar2.a.setParent(view, -1);
                        bVar2.a.setBoundsInParent(n);
                        t(i, bVar2);
                        bVar2.a.getBoundsInParent(this.e);
                        rect2 = this.d;
                        Rect rect3 = this.e;
                        rect2.offset(rect3.left, rect3.top);
                    }
                    bVar2.a.recycle();
                }
                this.d.offset(this.g[0] - this.i.getScrollX(), this.g[1] - this.i.getScrollY());
            }
            if (this.i.getLocalVisibleRect(this.f)) {
                this.f.offset(this.g[0] - this.i.getScrollX(), this.g[1] - this.i.getScrollY());
                if (this.d.intersect(this.f)) {
                    bVar.a.setBoundsInScreen(this.d);
                    rect2 = this.d;
                    if (rect2 != null && !rect2.isEmpty() && this.i.getWindowVisibility() == 0) {
                        ViewParent parent = this.i.getParent();
                        while (parent instanceof View) {
                            View view2 = (View) parent;
                            if (view2.getAlpha() <= 0.0f || view2.getVisibility() != 0) {
                                break;
                            }
                            parent = view2.getParent();
                        }
                        if (parent != null) {
                            i2 = 1;
                        }
                    }
                    if (i2 != 0) {
                        bVar.a.setVisibleToUser(true);
                    }
                }
            }
            return bVar;
        } else {
            throw new RuntimeException("Callbacks must not add ACTION_CLEAR_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()");
        }
    }

    /* JADX WARNING: Missing block: B:20:0x0053, code skipped:
            if (r8 != Integer.MIN_VALUE) goto L_0x0057;
     */
    public final boolean m(android.view.MotionEvent r8) {
        /*
        r7 = this;
        r0 = r7.h;
        r0 = r0.isEnabled();
        r1 = 1;
        r2 = 0;
        if (r0 == 0) goto L_0x0056;
    L_0x000a:
        r0 = r7.h;
        r0 = r0.isTouchExplorationEnabled();
        if (r0 != 0) goto L_0x0013;
    L_0x0012:
        goto L_0x0056;
    L_0x0013:
        r0 = r8.getAction();
        r3 = 7;
        r4 = 256; // 0x100 float:3.59E-43 double:1.265E-321;
        r5 = 128; // 0x80 float:1.794E-43 double:6.32E-322;
        r6 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        if (r0 == r3) goto L_0x003a;
    L_0x0020:
        r3 = 9;
        if (r0 == r3) goto L_0x003a;
    L_0x0024:
        r8 = 10;
        if (r0 == r8) goto L_0x0029;
    L_0x0028:
        return r2;
    L_0x0029:
        r8 = r7.m;
        if (r8 == r6) goto L_0x0039;
    L_0x002d:
        if (r8 != r6) goto L_0x0030;
    L_0x002f:
        goto L_0x0038;
    L_0x0030:
        r7.m = r6;
        r7.w(r6, r5);
        r7.w(r8, r4);
    L_0x0038:
        return r1;
    L_0x0039:
        return r2;
    L_0x003a:
        r0 = r8.getX();
        r8 = r8.getY();
        r8 = r7.n(r0, r8);
        r0 = r7.m;
        if (r0 != r8) goto L_0x004b;
    L_0x004a:
        goto L_0x0053;
    L_0x004b:
        r7.m = r8;
        r7.w(r8, r5);
        r7.w(r0, r4);
    L_0x0053:
        if (r8 == r6) goto L_0x0056;
    L_0x0055:
        goto L_0x0057;
    L_0x0056:
        r1 = 0;
    L_0x0057:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.k.a.a.m(android.view.MotionEvent):boolean");
    }

    public abstract int n(float f, float f2);

    public abstract void o(List<Integer> list);

    /* JADX WARNING: Removed duplicated region for block: B:115:0x0144 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:65:0x013f  */
    /* JADX WARNING: Missing block: B:61:0x0138, code skipped:
            if (r13 < ((r17 * r17) + ((r12 * 13) * r12))) goto L_0x013a;
     */
    public final boolean p(int r20, android.graphics.Rect r21) {
        /*
        r19 = this;
        r0 = r19;
        r1 = r20;
        r2 = r21;
        r3 = new java.util.ArrayList;
        r3.<init>();
        r0.o(r3);
        r4 = new b.f.i;
        r5 = 10;
        r4.m400init(r5);
        r5 = 0;
        r6 = 0;
    L_0x0017:
        r7 = r3.size();
        if (r6 >= r7) goto L_0x0027;
    L_0x001d:
        r7 = r0.l(r6);
        r4.g(r6, r7);
        r6 = r6 + 1;
        goto L_0x0017;
    L_0x0027:
        r3 = r0.l;
        r7 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        if (r3 != r7) goto L_0x002f;
    L_0x002d:
        r3 = 0;
        goto L_0x0035;
    L_0x002f:
        r3 = r4.d(r3);
        r3 = (b.i.k.y.b) r3;
    L_0x0035:
        r8 = 2;
        r9 = -1;
        r10 = 1;
        if (r1 == r10) goto L_0x0147;
    L_0x003a:
        if (r1 == r8) goto L_0x0147;
    L_0x003c:
        r8 = 130; // 0x82 float:1.82E-43 double:6.4E-322;
        r11 = 66;
        r12 = 33;
        r13 = 17;
        if (r1 == r13) goto L_0x0055;
    L_0x0046:
        if (r1 == r12) goto L_0x0055;
    L_0x0048:
        if (r1 == r11) goto L_0x0055;
    L_0x004a:
        if (r1 != r8) goto L_0x004d;
    L_0x004c:
        goto L_0x0055;
    L_0x004d:
        r1 = new java.lang.IllegalArgumentException;
        r2 = "direction must be one of {FOCUS_FORWARD, FOCUS_BACKWARD, FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}.";
        r1.<init>(r2);
        throw r1;
    L_0x0055:
        r14 = new android.graphics.Rect;
        r14.<init>();
        r15 = r0.l;
        r6 = "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}.";
        if (r15 == r7) goto L_0x006a;
    L_0x0060:
        r2 = r0.q(r15);
        r2 = r2.a;
        r2.getBoundsInParent(r14);
        goto L_0x0097;
    L_0x006a:
        if (r2 == 0) goto L_0x0070;
    L_0x006c:
        r14.set(r2);
        goto L_0x0097;
    L_0x0070:
        r2 = r0.i;
        r15 = r2.getWidth();
        r2 = r2.getHeight();
        if (r1 == r13) goto L_0x0094;
    L_0x007c:
        if (r1 == r12) goto L_0x0090;
    L_0x007e:
        if (r1 == r11) goto L_0x008c;
    L_0x0080:
        if (r1 != r8) goto L_0x0086;
    L_0x0082:
        r14.set(r5, r9, r15, r9);
        goto L_0x0097;
    L_0x0086:
        r1 = new java.lang.IllegalArgumentException;
        r1.<init>(r6);
        throw r1;
    L_0x008c:
        r14.set(r9, r5, r9, r2);
        goto L_0x0097;
    L_0x0090:
        r14.set(r5, r2, r15, r2);
        goto L_0x0097;
    L_0x0094:
        r14.set(r15, r5, r15, r2);
    L_0x0097:
        r2 = p;
        r15 = o;
        r7 = new android.graphics.Rect;
        r7.<init>(r14);
        if (r1 == r13) goto L_0x00cb;
    L_0x00a2:
        if (r1 == r12) goto L_0x00c2;
    L_0x00a4:
        if (r1 == r11) goto L_0x00b8;
    L_0x00a6:
        if (r1 != r8) goto L_0x00b2;
    L_0x00a8:
        r6 = r14.height();
        r6 = r6 + r10;
        r6 = -r6;
        r7.offset(r5, r6);
        goto L_0x00d3;
    L_0x00b2:
        r1 = new java.lang.IllegalArgumentException;
        r1.<init>(r6);
        throw r1;
    L_0x00b8:
        r6 = r14.width();
        r6 = r6 + r10;
        r6 = -r6;
        r7.offset(r6, r5);
        goto L_0x00d3;
    L_0x00c2:
        r6 = r14.height();
        r6 = r6 + r10;
        r7.offset(r5, r6);
        goto L_0x00d3;
    L_0x00cb:
        r6 = r14.width();
        r6 = r6 + r10;
        r7.offset(r6, r5);
    L_0x00d3:
        r2 = (b.k.a.a.b) r2;
        java.util.Objects.requireNonNull(r2);
        r2 = r4.i();
        r6 = new android.graphics.Rect;
        r6.<init>();
        r8 = 0;
        r16 = 0;
    L_0x00e4:
        if (r8 >= r2) goto L_0x01bc;
    L_0x00e6:
        r11 = r4.a;
        if (r11 == 0) goto L_0x00ed;
    L_0x00ea:
        r4.c();
    L_0x00ed:
        r11 = r4.c;
        r11 = r11[r8];
        r11 = (b.i.k.y.b) r11;
        if (r11 != r3) goto L_0x00f6;
    L_0x00f5:
        goto L_0x0144;
    L_0x00f6:
        r12 = r15;
        r12 = (b.k.a.a.a) r12;
        r12.a(r11, r6);
        r12 = b.i.b.f.C0(r14, r6, r1);
        if (r12 != 0) goto L_0x0103;
    L_0x0102:
        goto L_0x013c;
    L_0x0103:
        r12 = b.i.b.f.C0(r14, r7, r1);
        if (r12 != 0) goto L_0x010a;
    L_0x0109:
        goto L_0x013a;
    L_0x010a:
        r12 = b.i.b.f.B(r1, r14, r6, r7);
        if (r12 == 0) goto L_0x0111;
    L_0x0110:
        goto L_0x013a;
    L_0x0111:
        r12 = b.i.b.f.B(r1, r14, r7, r6);
        if (r12 == 0) goto L_0x0118;
    L_0x0117:
        goto L_0x013c;
    L_0x0118:
        r12 = b.i.b.f.D0(r1, r14, r6);
        r13 = b.i.b.f.E0(r1, r14, r6);
        r17 = r12 * 13;
        r17 = r17 * r12;
        r13 = r13 * r13;
        r13 = r13 + r17;
        r12 = b.i.b.f.D0(r1, r14, r7);
        r17 = b.i.b.f.E0(r1, r14, r7);
        r18 = r12 * 13;
        r18 = r18 * r12;
        r17 = r17 * r17;
        r12 = r17 + r18;
        if (r13 >= r12) goto L_0x013c;
    L_0x013a:
        r12 = 1;
        goto L_0x013d;
    L_0x013c:
        r12 = 0;
    L_0x013d:
        if (r12 == 0) goto L_0x0144;
    L_0x013f:
        r7.set(r6);
        r16 = r11;
    L_0x0144:
        r8 = r8 + 1;
        goto L_0x00e4;
    L_0x0147:
        r2 = r0.i;
        r6 = b.i.k.o.a;
        r2 = r2.getLayoutDirection();
        if (r2 != r10) goto L_0x0153;
    L_0x0151:
        r2 = 1;
        goto L_0x0154;
    L_0x0153:
        r2 = 0;
    L_0x0154:
        r6 = p;
        r7 = o;
        r6 = (b.k.a.a.b) r6;
        java.util.Objects.requireNonNull(r6);
        r6 = r4.i();
        r11 = new java.util.ArrayList;
        r11.<init>(r6);
        r12 = 0;
    L_0x0167:
        if (r12 >= r6) goto L_0x017c;
    L_0x0169:
        r13 = r4.a;
        if (r13 == 0) goto L_0x0170;
    L_0x016d:
        r4.c();
    L_0x0170:
        r13 = r4.c;
        r13 = r13[r12];
        r13 = (b.i.k.y.b) r13;
        r11.add(r13);
        r12 = r12 + 1;
        goto L_0x0167;
    L_0x017c:
        r6 = new b.k.a.d;
        r6.m557init(r2, r7);
        java.util.Collections.sort(r11, r6);
        if (r1 == r10) goto L_0x01a6;
    L_0x0186:
        if (r1 != r8) goto L_0x019e;
    L_0x0188:
        r1 = r11.size();
        if (r3 != 0) goto L_0x0190;
    L_0x018e:
        r2 = -1;
        goto L_0x0194;
    L_0x0190:
        r2 = r11.lastIndexOf(r3);
    L_0x0194:
        r2 = r2 + r10;
        if (r2 >= r1) goto L_0x019c;
    L_0x0197:
        r6 = r11.get(r2);
        goto L_0x01b8;
    L_0x019c:
        r6 = 0;
        goto L_0x01b8;
    L_0x019e:
        r1 = new java.lang.IllegalArgumentException;
        r2 = "direction must be one of {FOCUS_FORWARD, FOCUS_BACKWARD}.";
        r1.<init>(r2);
        throw r1;
    L_0x01a6:
        r1 = r11.size();
        if (r3 != 0) goto L_0x01ad;
    L_0x01ac:
        goto L_0x01b1;
    L_0x01ad:
        r1 = r11.indexOf(r3);
    L_0x01b1:
        r1 = r1 + r9;
        if (r1 < 0) goto L_0x019c;
    L_0x01b4:
        r6 = r11.get(r1);
    L_0x01b8:
        r16 = r6;
        r16 = (b.i.k.y.b) r16;
    L_0x01bc:
        r1 = r16;
        if (r1 != 0) goto L_0x01c3;
    L_0x01c0:
        r7 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        goto L_0x01dd;
    L_0x01c3:
        r2 = r4.a;
        if (r2 == 0) goto L_0x01ca;
    L_0x01c7:
        r4.c();
    L_0x01ca:
        r2 = r4.d;
        if (r5 >= r2) goto L_0x01d9;
    L_0x01ce:
        r2 = r4.c;
        r2 = r2[r5];
        if (r2 != r1) goto L_0x01d6;
    L_0x01d4:
        r9 = r5;
        goto L_0x01d9;
    L_0x01d6:
        r5 = r5 + 1;
        goto L_0x01ca;
    L_0x01d9:
        r7 = r4.f(r9);
    L_0x01dd:
        r1 = r0.v(r7);
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.k.a.a.p(int, android.graphics.Rect):boolean");
    }

    public b.i.k.y.b q(int i) {
        if (i != -1) {
            return l(i);
        }
        AccessibilityNodeInfo obtain = AccessibilityNodeInfo.obtain(this.i);
        b.i.k.y.b bVar = new b.i.k.y.b(obtain);
        View view = this.i;
        WeakHashMap weakHashMap = o.a;
        view.onInitializeAccessibilityNodeInfo(obtain);
        ArrayList arrayList = new ArrayList();
        o(arrayList);
        if (bVar.a.getChildCount() <= 0 || arrayList.size() <= 0) {
            int size = arrayList.size();
            for (int i2 = 0; i2 < size; i2++) {
                bVar.a.addChild(this.i, ((Integer) arrayList.get(i2)).intValue());
            }
            return bVar;
        }
        throw new RuntimeException("Views cannot have both real and virtual children");
    }

    public abstract boolean r(int i, int i2, Bundle bundle);

    public void s(b.i.k.y.b bVar) {
    }

    public abstract void t(int i, b.i.k.y.b bVar);

    public void u(int i, boolean z) {
    }

    public final boolean v(int i) {
        if (!this.i.isFocused() && !this.i.requestFocus()) {
            return false;
        }
        int i2 = this.l;
        if (i2 == i) {
            return false;
        }
        if (i2 != Integer.MIN_VALUE) {
            k(i2);
        }
        this.l = i;
        u(i, true);
        w(i, 8);
        return true;
    }

    public final boolean w(int i, int i2) {
        if (i == Integer.MIN_VALUE || !this.h.isEnabled()) {
            return false;
        }
        ViewParent parent = this.i.getParent();
        if (parent == null) {
            return false;
        }
        AccessibilityEvent obtain;
        if (i != -1) {
            obtain = AccessibilityEvent.obtain(i2);
            b.i.k.y.b q = q(i);
            obtain.getText().add(q.g());
            obtain.setContentDescription(q.e());
            obtain.setScrollable(q.a.isScrollable());
            obtain.setPassword(q.a.isPassword());
            obtain.setEnabled(q.a.isEnabled());
            obtain.setChecked(q.a.isChecked());
            if (obtain.getText().isEmpty() && obtain.getContentDescription() == null) {
                throw new RuntimeException("Callbacks must add text or a content description in populateEventForVirtualViewId()");
            }
            obtain.setClassName(q.a.getClassName());
            obtain.setSource(this.i, i);
            obtain.setPackageName(this.i.getContext().getPackageName());
        } else {
            obtain = AccessibilityEvent.obtain(i2);
            this.i.onInitializeAccessibilityEvent(obtain);
        }
        return parent.requestSendAccessibilityEvent(this.i, obtain);
    }

    public final void x(int i) {
        int i2 = this.m;
        if (i2 != i) {
            this.m = i;
            w(i, AesLen.ROOTKEY_COMPONET_LEN);
            w(i2, 256);
        }
    }
}
